<template>
	<div>
		<div class="car_img">
			<img :src="truckBasicInfo.truckInfo && truckBasicInfo.truckInfo.logo" >
		</div>
		<div>
			<h5 class="lhh40 pl10 fs14 c333 bg_white">参数配置</h5>
			<div>
				<table  width="100%"  cellspacing="0" cellpadding="0" border-collapse="collapse">
					<tr v-for="(item,index) in truckBasicInfo.indexParam" :key="index">
						<td width="100">{{item.param_name}}</td>
						<td class="bg_white">{{item.param_value}}</td>
					</tr>
				</table>
				<router-link class="lhh40 textc bg_white fs12 c92 block" :to="{path:'/detail/config',query:{id:truck_info_id}}">查看更多配置 ></router-link>
			</div>
		</div>
		<div>
			<h5 class="lhh40 pl10 fs14 c333  clearfix pl10 pr10 bg_agray" @click="showAddress = true">
				<span class="fl">经销商</span>
				<span class="fr c_main"><i class="iconfont fs16 mr5 align_middle">&#xe62e;</i><i class="align_middle">{{address}}</i></span>	
			</h5>
			<div class="busniess bg_white" >
				<template v-if="truckDealerInfo.length > 0">
					<busniessItem  v-for="(item,index) in truckDealerInfo" :info="item" :key="index"></busniessItem>
				</template>
				<div v-else class="textc pb10 pt10"> 
					<img src="../../images/nodata.png">
					<div class="c_999 mt15">当地暂无经销商</div>
					<div class="mt10  c_main" @click="showAddress = true">切换地区</div>
				</div>
			</div>
		</div>
		 <x-address style="display:none;" popup-title="请选择城市" title="456" v-model="city_name" :list="addressData" placeholder="请选择地址" :show.sync="showAddress"  hide-district @on-hide="select"></x-address>
		<div style="height:2.13333rem;"></div>
		<router-link class="fullbutton" :to="{path:'/ask/askprice',query:{id:truck_info_id}}">询底价</router-link>
		<scrollTop></scrollTop>
	</div>
</template>

<script>
	import busniessItem from '../../base/businessItem.vue'
	import {mapActions, mapGetters} from 'vuex'
	import { XAddress, ChinaAddressV4Data,Value2nameFilter as value2name } from 'vux'
	import scrollTop from '../../base/scrollTop.vue'
	export default {
		components:{
			busniessItem,
			XAddress,
			scrollTop
		},
		computed:{
			...mapGetters('detail',[
				'truckBasicInfo',
				'truckDealerInfo'
			])
		},
		data () {
			return {
				truck_info_id:'',
				addressData:ChinaAddressV4Data	,
				city_name:[],
				showAddress:false,
				address:'江苏省 无锡市'
			}
		},
		methods:{
			...mapActions('detail',[
				'getTruckBaseInfo',
				'getTruckDealerInfo'
			]),
			select (value) {
				this.address = value2name(this.city_name, ChinaAddressV4Data) 
				var city_name = this.address.split(' ')[1].indexOf('市辖区') > -1 ? this.address.split(' ')[0]: this.address.split(' ')[1];
				this.getTruckDealerInfo({truckid:this.truck_info_id,city_name});
			}
		},
		mounted(){
			this.truck_info_id = this.$route.query.id;
			this.getTruckBaseInfo({truck_info_id:this.truck_info_id}).then((data) => {
				this.$parent.title = data.truckInfo.name
			})
			this.getTruckDealerInfo({truckid:this.truck_info_id,city_name:'无锡'});
		}
	}
</script>

<style lang = 'scss' scoped>
	.c92 {
		color: #929292;
	}
	table {
		border: 1px solid #eee;
		td {
			padding-left: 0.26667rem;
		}
	}
	.car_img {
		height: 6.93333rem;		
		img {
			height: 100%;
			width: 100%; 
		}
	}

</style>